<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>
        项目信息-人员信息
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../../../../css/main.css" media="all">
    <link rel="stylesheet" href="../../../../lib/layui/css/layui_2.5.7.css">
    <script type="text/javascript" src="../../../../lib/loading/okLoading.js"></script>
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">

</head>
<!--借还流水-->
<style>
    .layui-form-label {
        width: 150px !important;
    }
</style>

<body>
<div class="x-nav">
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon"
                                                                        style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body" id="app">
    <div class="main_box">
        <div class="panel-heading">
            <ul class="nav nav-tabs" id="navTabs">
                <li class="active"><a class="receivePane" data-tab=""  href="#" onclick="p_admin_add('项目详情','essential_information.html?recordId='+recordId +'&businessTypeId=' + businessTypeId,'1200','600')">基本信息</a></li>
                <li class=""><a class="payPane" data-tab="" href="#" onclick="p_admin_add('项目详情','personnel_information/personnel_information.html?recordId='+recordId +'&businessTypeId=' + businessTypeId,'1200','600')">人员信息</a></li>
                <li class=""><a class="payPane" data-tab="" href="#" onclick="p_admin_add('项目详情','tracking_phase/tracking_phase.html?recordId='+recordId +'&businessTypeId=' + businessTypeId,'1200','600')">跟踪阶段</a></li>
                <li class=""><a class="payPane" data-tab="" href="#" onclick="p_admin_add('项目详情','visit_records/visit_records.html?recordId='+recordId +'&businessTypeId=' + businessTypeId,'1200','600')">拜访记录</a></li>
                <li class=""><a class="payPane" data-tab="" href="#" onclick="p_admin_add('项目详情','project_log/project_log.html?recordId='+recordId +'&businessTypeId=' + businessTypeId,'1200','600')">项目日志</a></li>

            </ul>
        </div>
    </div>



    <form class="layui-form layui-form-pane" id="add" lay-filter="updateInfo">
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <div class=" layui-form-item">
                    <label class="layui-form-label"> <span class='x-red'>*</span>项目名称</label>
                    <div class="layui-input-inline">
                        <input  autocomplete="off"  type="text" name="name" v-model="name"
                               lay-verify="required" placeholder="名称" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">省市区</label>
                    <div class="layui-input-inline">
                        <select name="addressProvince" lay-filter='sheng' lay-verify="" id="sheng">
                            <option value="">请选择省</option>
                            <option v-for='item in sheng' :value="item.id">{{item.name}}</option>
                        </select>

                    </div>
                    <div class="layui-input-inline">
                        <select name="addressCity" lay-filter="shi" lay-verify="" id="shi">
                            <option value="">请选择市</option>
                            <option v-for='item in shi' :value="item.id">{{item.name}}</option>
                        </select>
                    </div>
                    <div class="layui-input-inline">
                        <select name="addressArea" lay-filter="qu" lay-verify="" id="qu">
                            <option value="">请选择县/区</option>
                            <option v-for='item in qu' :value="item.id">{{item.name}}</option>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">项目地址</label>
                    <div class="layui-input-inline">
                        <input  autocomplete="off"  type="text" name="address" v-model="address"
                               placeholder="项目地址" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label"> <span class='x-red'>*</span>业务合作</label>
                    <div class="layui-input-inline">
                        <input  autocomplete="off"  type="text" name="business" v-model="business"
                               lay-verify="required" placeholder="业务合作" class="layui-input" disabled="disabled">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"> <span class='x-red'>*</span>项目级别</label>
                    <div class="layui-input-inline">

                        <select name="projectLevel" id="level" lay-verify="required">
                            <option value="">-请选择-</option>
                            <option value="1">普通</option>
                            <option value="2">重要</option>
                        </select>
                    </div>
                </div>



                <div class="layui-form-item">
                    <label class="layui-form-label"> <span class='x-red'></span>备注信息</label>
                    <div style="width: 70%" class="layui-input-inline">
                         <textarea name="memo" placeholder="请输入内容" v-model="remark"
                                   class="layui-textarea"></textarea>
                    </div>
                </div>

                <div style="text-align: center" class="layui-form-item">
                    <button class="layui-btn" type="button" lay-filter="sub" lay-submit="sub">
                        保存
                    </button>
                </div>
                <!--</form>-->
                <div style="height:20px;"></div>
            </div>


        </div>
        <p style="color: red">注意：保存后，上面的内容才生效。同时请认真核对内容是否正确！！！！！</p>
    </form>
</div>
<script type="text/javascript" src="../../../../js/jquery.min.js"></script>
<script type="text/javascript" src="../../../../js/myAjax.js"></script>
<script type="text/javascript" src="../../../../js/pub.js"></script>
<script src="../../../../lib/layui/layui2.5.7.js" charset="utf-8"></script>
<script src="../../../../js/x-layui.js" charset="utf-8"></script>
<script src="../../../../js/vue.min.js" charset="utf-8"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.5/js/bootstrap.min.js"></script>

<script>
    layui.use(['element', 'layer', 'form', 'laydate'], function () {
        $ = layui.jquery;//jquery
        element = layui.element;//面包导航
        layer = layui.layer;//弹出层
        laydate = layui.laydate;//日期插件
        form = layui.form;
        okLoading.close($);
    })

</script>
<script>

    var recordId = getQueryVariable("recordId");

    var businessTypeId=getQueryVariable("businessTypeId");




</script>
<script>

    var recordId = getQueryVariable("recordId");
    const vm = new Vue({
        el: "#app",
        data: {
            name :null,
            address:null,
            customer:null,
            business:null,
            level :null,
            remark :null,
            sheng: [],
            shi: [],
            qu: [],
            shengVal: '',
            shiVal: '',
            quVal: ''

        },






        created() {

            this.getSheng(1);
            var that = this;
            let request1 = {
                url: 'xa/project/findProjectInfo',
                data: {
                    userId: $userId,
                    id:recordId
                },
                method: "get"
            }
            sendRequest(request1, (res) => {
                that.getShi(res.data.addressProvince);
                that.getQu(res.data.addressCity);
            })


            var form = layui.form;
            let request = {
                url: 'xa/project/findProjectInfo',
                data: {
                    userId: $userId,
                    id: recordId
                },
                method: "get"
            }
            sendRequest(request, (res) => {
               this.name=res.data.name;

               this.address=res.data.address;

               this.customer=res.data.customerName;

               if(res.data.businessTypeId === 1){
                   this.business='销售';
               }else
               if(res.data.businessTypeId === 2){
                   this.business="工程";
               }

                var codeTypeSelect = document.getElementById("level");
                for(var i=0;i<codeTypeSelect.length;i++){
                    if(codeTypeSelect[i].value==res.data.projectLevel)
                        codeTypeSelect[i].selected = true;
                }





               this.remark=res.data.memo;
                    layui.use(['table', 'form', 'upload','layer'], function() {

                        var form = layui.form;

                            //表单赋值
                            form.val("updateInfo", { //updateInfo 即 class="layui-form" 所在元素属性 lay-filter="" 对应的值

                                "addressProvince": res.data.addressProvince,
                                "addressCity": res.data.addressCity,
                                "addressArea": res.data.addressArea,

                            });
                        form.render();
                    });


            });



        },

        methods:{
            getSheng: function(id) {
                var that = this;
                let request = {
                    url: 'other/region/getRegionByParentId',
                    data: {
                        userId: $userId,
                        parentId:id
                    },
                    method: "get"
                }
                sendRequest(request, (res) => {
                    that.sheng = res;
                })
            },
            getShi: function(id) {
                if (id != null) {
                    var that = this;
                    let request = {
                        url: 'other/region/getRegionByParentId',
                        data: {
                            userId: $userId,
                            parentId:id
                        },
                        method: "get"
                    }
                    sendRequest(request, (res) => {
                        that.shi = res;
                    })
                }
            },
            getQu: function(id) {
                if (id != null) {
                    var that = this;
                    let request = {
                        url: 'other/region/getRegionByParentId',
                        data: {
                            userId: $userId,
                            parentId: id
                        },
                        method: "get"
                    }
                    sendRequest(request, (res) => {
                        that.qu = res;
                    })
                }
            },
        },

        computed: {},
        mounted(){
            var that = this;

            layui.use(['laydate', 'form', 'layer'],
                function () {
                    var form = layui.form;
                    var layer = layui.layer;
                    var laydate = layui.laydate;

                    //监听省选择
                    form.on('select(sheng)', function(data) {
                        that.shengVal = data.elem[data.elem.selectedIndex].text;
                        that.getShi(data.value);
                        setTimeout(() => {
                            form.render('select');
                        }, 200);
                    });
                    //监听市选择
                    form.on('select(shi)', function(data) {
                        that.shiVal = data.elem[data.elem.selectedIndex].text;
                        that.getQu(data.value);
                        setTimeout(() => {
                            form.render('select');
                        }, 200);
                        setTimeout(() => {
                            form.render('select');
                        }, 200);
                    });
                    //监听区选择
                    form.on('select(qu)', function(data) {
                        that.quVal = data.elem[data.elem.selectedIndex].text;
                        setTimeout(() => {
                            form.render('select');
                        }, 200);
                    });

                    //监听提交
                    form.on('submit(sub)',
                        function (data) {
                            let form = data.field;
                            form.id=recordId;
                            form.userId=$userId;
                            form.operatorId=$userId;
                            let request = {
                                url: 'xa/project/update',
                                data: form,
                                method: "post",
                            };
                            sendRequest(request, (data) => {
                                if (data.code === 0) {
                                    layer.alert("操作成功", {
                                            icon: 6
                                        },
                                        function () {
                                            var index = parent.layer.getFrameIndex(window.name);
                                            parent.layer.close(index);
                                            parent.location.reload();

                                        });
                                } else {
                                    layer.alert(data.msg, {
                                        icon: 5
                                    })
                                }
                            });
                            return false;
                        });


                });






        }


    });

    function p_admin_add(title,url,w,h){
        p_admin_show(title,url,w,h);
    }

</script>

</body>

</html>
